package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.Content;
import com.ruoyi.system.api.RemoteManagerService;
import com.ruoyi.system.api.domain.Goods;
import com.ruoyi.system.api.domain.GoodsDesc;
import com.ruoyi.system.api.domain.Item;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteManagerFallbackFactory implements FallbackFactory<RemoteManagerService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteManagerFallbackFactory.class);

    @Override
    public RemoteManagerService create(Throwable throwable)
    {
        return new RemoteManagerService() {

            //1. 根据分类id查询广告列表
            @Override
            public R<List<Content>> findContentsByCategoryId(Long categoryId) {
                return R.fail("根据广告分类id查询广告列表失败:" + throwable.getMessage());
            }
            //2. 查询审核通过的sku商品列表
            @Override
            public R<List<Item>> findAllItems() {
                return R.fail("查询审核通过的sku商品列表失败:" + throwable.getMessage());
            }
            //3. 根据id查询商品失败
            @Override
            public R<Goods> findById(Long id) {
                return R.fail("根据id查询商品失败:" + throwable.getMessage());
            }
            //4. 根据商品id查询商品描述信息
            @Override
            public R<GoodsDesc> findGoodsDescById(Long goodsId) {
                return R.fail("根据id查询商品描述信息失败:" + throwable.getMessage());
            }

            //5. 根据goodsId查询sku商品列表
            @Override
            public R<List<Item>> findSkuList(Long goodsId) {
                return R.fail("根据id查询sku商品列表失败:" + throwable.getMessage());
            }
            //6. 根据sku商品主键id查询sku商品
            @Override
            public R<Item> findItemById(Long id) {
                return R.fail("根据id查询sku商品失败:" + throwable.getMessage());
            }
        };
    }
}
